const resData = require('./res.js')

const crypto = require('crypto')
// console.log(resData)

module.exports = function login(req, res){
  if(req.query.key === 'i am pig'){
    const hash = crypto.createHash('md5')
    const {code, data, message} = resData.success
    // console.log(code, data, message)
    hash.update(req.query.key);
    const sendData = {
      code: code,
      data: hash.digest('hex'),
      message: message,
    }
    res.send(sendData)
  }
}